<template>
	<view class="container">
		<view class="tabs">
			<u-tabs :scrollable="false" :list="tabs" @click="onTabs"></u-tabs>
		</view>
		<view class="lists" v-if="lists.length > 0">
			<view class="item" v-for="(item,index) in lists" :key="index">
				<view class="top">
					<view class="left">{{ item.order_no }}</view>
					<view class="right">{{ item.pay_status == 10?'未支付':'已支付' }}</view>
				</view>
				<view class="middle">
					<view class="cover">
						<u--image radius="80" :showLoading="true" :src="item.user.avatar.file_path" width="80px"
							height="80px"></u--image>
					</view>
					<view class="content">
						<view class="title">{{ item.opus.title }}</view>
						<view class="label">{{ item.link_name }} | {{ item.link_phone }}</view>
						<view class="price">￥{{ item.pay_price }}</view>
					</view>
					<view class="number">
						<view class="text">x{{ item.number }}</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else>
			<u-empty mode="data" text="暂无销售记录,加油鸭~!" icon="http://cdn.uviewui.com/uview/empty/data.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	import {
		order
	} from '@/api/author/opus.js';
	export default {
		data() {
			return {
				state: -1,
				page: 1,
				is_reach: false,
				lists: [],
				tabs: [{
					name: '全部',
					value: -1
				}, {
					name: '已支付',
					value: 20
				}, {
					name: '未支付',
					value: 10
				}]
			};
		},
		onLoad() {
			this.getOrder()
		},
		onReachBottom() {
			let _this = this
			_this.is_reach = true
			_this.page = _this.page + 1
			_this.getOrder()
		},
		methods: {
			onTabs(e) {
				this.state = e.value
				this.page = 1
				this.getOrder()
			},
			getOrder() {
				let _this = this
				order({
					state: _this.state,
					page: _this.page
				}).then(res => {
					if (_this.is_reach) {
						_this.lists = [...this.opus, ...res.data.order.data]
					} else {
						_this.lists = res.data.order.data
					}
					_this.is_reach = false
				}).catch(err => {

				})
			}
		}
	}
</script>

<style lang="scss">
	.tabs {
		background-color: #fff;
	}

	.lists {
		width: 96%;
		margin: 0 auto;

		.item {
			background-color: #fff;
			padding: 15rpx;
			margin: 15rpx 0rpx;
			border-radius: 10rpx;

			.top {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				border-bottom: 1rpx solid #f4f4f4;
				padding: 15rpx 0rpx;

				.left {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 40rpx;
				}

				.right {
					font-size: 28rpx;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #3072f6;
					line-height: 40rpx;
				}
			}

			.middle {
				display: flex;
				flex-direction: row;
				padding: 30rpx 0rpx;

				.cover {
					width: 30%;
				}

				.content {
					width: 60%;

					.title {
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 36rpx;
					}

					.label {
						margin: 10rpx 0rpx;
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #666666;
						line-height: 34rpx;
					}

					.price {
						font-size: 28rpx;
						font-family: PingFangSC-Semibold, PingFang SC;
						font-weight: 600;
						color: #ff3637;
						line-height: 40rpx;
					}
				}

				.number {
					width: 10%;
					text-align: right;
				}
			}
		}
	}
</style>
